package com.koala.learn.threadlearn.charter1;


import java.util.concurrent.DelayQueue;

/**
 * 学习延时队列
 *
 * @Date 2022/2/26 12:04
 * @Created by koala
 */

public class Info {

    public static void main(String[] args) throws InterruptedException {
        DelayQueue<DelayElements> delayQueue = new DelayQueue();
        // 创建消息内容
        String msg = "你好 sitian";
        delayQueue.offer(new DelayElements(msg, 1));
        delayQueue.offer(new DelayElements(msg, 3));
        delayQueue.offer(new DelayElements(msg, 5));
        while (!delayQueue.isEmpty()) {
            DelayElements poll = delayQueue.take();
            System.out.println(poll.getKey());
        }
    }


}
